package com.ruoyi.bussiness.controller;

import java.util.List;

import com.ruoyi.bussiness.domain.PlanDetailsRsp;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.CcyTradeSuccess;
import com.ruoyi.bussiness.service.ICcyTradeSuccessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 成交订单Controller
 * 
 * @author wzy
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/bussiness/success")
public class CcyTradeSuccessController extends BaseController
{
    @Autowired
    private ICcyTradeSuccessService ccyTradeSuccessService;

    @PostMapping("/selectTotal")
    public List<PlanDetailsRsp> selectTotal(@RequestBody CcyTradeSuccess ccyTradeSuccess){
        return ccyTradeSuccessService.selectTotal(ccyTradeSuccess);
    }

    /**
     * 查询成交订单列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcyTradeSuccess ccyTradeSuccess)
    {
        startPage();
        List<CcyTradeSuccess> list = ccyTradeSuccessService.selectCcyTradeSuccessList(ccyTradeSuccess);
        return getDataTable(list);
    }

    /**
     * 导出成交订单列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:export')")
    @Log(title = "成交订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcyTradeSuccess ccyTradeSuccess)
    {
        List<CcyTradeSuccess> list = ccyTradeSuccessService.selectCcyTradeSuccessList(ccyTradeSuccess);
        ExcelUtil<CcyTradeSuccess> util = new ExcelUtil<CcyTradeSuccess>(CcyTradeSuccess.class);
        util.exportExcel(response, list, "成交订单数据");
    }

    /**
     * 获取成交订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccyTradeSuccessService.selectCcyTradeSuccessById(id));
    }

    /**
     * 新增成交订单
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:add')")
    @Log(title = "成交订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcyTradeSuccess ccyTradeSuccess)
    {
        return toAjax(ccyTradeSuccessService.insertCcyTradeSuccess(ccyTradeSuccess));
    }

    /**
     * 修改成交订单
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:edit')")
    @Log(title = "成交订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcyTradeSuccess ccyTradeSuccess)
    {
        return toAjax(ccyTradeSuccessService.updateCcyTradeSuccess(ccyTradeSuccess));
    }

    /**
     * 删除成交订单
     */
    @PreAuthorize("@ss.hasPermi('bussiness:success:remove')")
    @Log(title = "成交订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccyTradeSuccessService.deleteCcyTradeSuccessByIds(ids));
    }
}
